package biz.obake.team.touchprotector.features.upsidedown;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.app.c;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.g.d;

public class UpsideDownActivity extends c implements SensorEventListener {
    private TextView t;
    private TextView u;
    private SeekBar v;
    private TextView w;
    private SeekBar x;
    private d y = new d(this, 1, 2, "UpDownSense");

    class a implements SeekBar.OnSeekBarChangeListener {
        a() {
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            biz.obake.team.touchprotector.g.a.q("upside_down_sensitivity", -((i * 10) + 10));
            UpsideDownActivity.this.G();
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    }

    class b implements SeekBar.OnSeekBarChangeListener {
        b() {
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            biz.obake.team.touchprotector.g.a.q("right_side_up_sensitivity", (i * 10) + 10);
            UpsideDownActivity.this.G();
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    }

    /* access modifiers changed from: protected */
    public void G() {
        int j = biz.obake.team.touchprotector.g.a.j("upside_down_sensitivity");
        int i = ((-j) - 10) / 10;
        int max = this.v.getMax();
        int i2 = 0;
        if (i < 0) {
            i = 0;
        } else if (max < i) {
            i = max;
        }
        String replace = biz.obake.team.touchprotector.c.w(R.string.upsidedown_sensitivity_activity_lock_angle).replace("{0}", Integer.toString(j));
        this.v.setProgress(i);
        this.u.setText(replace);
        int j2 = biz.obake.team.touchprotector.g.a.j("right_side_up_sensitivity");
        int i3 = (j2 - 10) / 10;
        int max2 = this.x.getMax();
        if (i3 >= 0) {
            i2 = max2 < i3 ? max2 : i3;
        }
        String replace2 = biz.obake.team.touchprotector.c.w(R.string.upsidedown_sensitivity_activity_unlock_angle).replace("{0}", Integer.toString(j2));
        this.x.setProgress(i2);
        this.w.setText(replace2);
    }

    public void onAccuracyChanged(Sensor sensor, int i) {
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.upsidedown_sensitivity_activity);
        this.t = (TextView) findViewById(R.id.currentDegreeText);
        this.u = (TextView) findViewById(R.id.upsideDownDegreeText);
        this.v = (SeekBar) findViewById(R.id.upsideDownDegreeBar);
        this.w = (TextView) findViewById(R.id.rightSideUpDegreeText);
        this.x = (SeekBar) findViewById(R.id.rightSideUpDegreeBar);
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        super.onPause();
        this.v.setOnSeekBarChangeListener((SeekBar.OnSeekBarChangeListener) null);
        this.x.setOnSeekBarChangeListener((SeekBar.OnSeekBarChangeListener) null);
        this.y.j();
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        this.v.setOnSeekBarChangeListener(new a());
        this.x.setOnSeekBarChangeListener(new b());
        G();
        this.t.setText(biz.obake.team.touchprotector.c.w(R.string.upsidedown_sensitivity_acitivity_current_angle).replace("{0}", "-"));
        this.y.h();
    }

    public void onSensorChanged(SensorEvent sensorEvent) {
        float[] fArr = sensorEvent.values;
        float f = fArr[0];
        float f2 = fArr[1];
        float f3 = fArr[2];
        this.t.setText(biz.obake.team.touchprotector.c.w(R.string.upsidedown_sensitivity_acitivity_current_angle).replace("{0}", String.format("%3s", new Object[]{Integer.toString((int) Math.toDegrees(Math.atan(((double) f2) / Math.sqrt((double) ((f * f) + (f3 * f3))))))})));
    }
}
